package io.openkunlun.javarpc.codegen;

import java.util.List;

public class RpcMethod {

    private final String methodId;
    private final String methodName;
    private final List<RpcParameter> parameters;
    private final List<String> exceptions;
    private final String returnType;
    private final String returnCastType;
    private final boolean ignored;

    private RpcMethod(Builder builder) {
        this.methodId = builder.methodId;
        this.methodName = builder.methodName;
        this.parameters = builder.parameters;
        this.exceptions = builder.exceptions;
        this.returnType = builder.returnType;
        this.returnCastType = builder.returnCastType;
        this.ignored = builder.ignored;
    }

    public String getMethodId() {
        return methodId;
    }

    public String getMethodName() {
        return methodName;
    }

    public List<RpcParameter> getParameters() {
        return parameters;
    }

    public List<String> getExceptions() {
        return exceptions;
    }

    public String getReturnType() {
        return returnType;
    }

    public String getReturnCastType() {
        return returnCastType;
    }

    public boolean isIgnored() {
        return ignored;
    }

    static Builder newBuilder() {
        return new Builder();
    }

    static final class Builder {
        private String methodId;
        private String methodName;
        private List<RpcParameter> parameters;
        private List<String> exceptions;
        private String returnType;
        private String returnCastType;
        private boolean ignored;

        private Builder() {
        }

        public Builder methodId(String methodId) {
            this.methodId = methodId;
            return this;
        }

        public Builder methodName(String methodName) {
            this.methodName = methodName;
            return this;
        }

        public Builder parameters(List<RpcParameter> parameters) {
            this.parameters = parameters;
            return this;
        }

        public Builder exceptions(List<String> exceptions) {
            this.exceptions = exceptions;
            return this;
        }

        public Builder returnType(String returnType) {
            this.returnType = returnType;
            return this;
        }

        public Builder returnCastType(String returnCastType) {
            this.returnCastType = returnCastType;
            return this;
        }

        public Builder ignored(boolean ignored) {
            this.ignored = ignored;
            return this;
        }

        public RpcMethod build() {
            return new RpcMethod(this);
        }
    }
}
